{extend name="base" /}
{block name="body"}

<div class="am-padding am-padding-bottom-0">
	<strong class="am-text-primary am-text-lg">后台权限</strong> / <small>Admin auth</small>
</div>

<div class="am-padding am-btn-toolbar">
	<div class="am-btn-group am-btn-group-xs">
		<a href="{:url('admin/auth/add')}" class="am-btn am-btn-default"><span class="am-icon-plus"></span> 新增</a>
		<button type="button" class="am-btn am-btn-default"><span class="am-icon-trash-o"></span> 删除</button>
	</div>
</div>

<div class="am-g">
	<div class="am-u-sm-12">
		<div class="am-padding am-scrollable-horizontal">
			<table class="am-table am-table-bd am-table-striped am-text-nowrap am-table-hover am-auth-table">
				<thead>
					<tr>
						<th>#</th>
						<th></th>
						<th>权限名称</th>
						<th></th>
						<th>控制器/方法</th>
						<th></th>
						<th>排序</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
					{foreach name="admin_menu_level_list" item="vo"}
					<tr class="level-{$vo.lvl}">
						<td>{$vo.id}</td>
						<td><i class="{$vo.icon} am-icon-fw"></i></td>
						<td>{$vo.title}</td>
						
						<td>
							{eq name="$vo.auth_open" value="1"}
								<a href="{:url('admin/auth/setStatus',['id'=>$vo.id,'auth_open'=>0])}" data-param="" class="am-icon-shield am-text-success ajax-get" title="设置：不验证权限"></a>
							{else/}
								<a href="{:url('admin/auth/setStatus',['id'=>$vo.id,'auth_open'=>1])}" data-param="" class="am-icon-times am-text-danger ajax-get" title="设置：验证权限"></a>
							{/eq}
						</td>
						<td>{$vo.name}</td>
						<td>
							{eq name="$vo.status" value="1"}
								<a href="{:url('admin/auth/setStatus',['id'=>$vo.id,'status'=>0])}" data-param="" class="am-icon-toggle-on am-text-success ajax-get" title="设置：不显示"></a>
							{else/}
								<a href="{:url('admin/auth/setStatus',['id'=>$vo.id,'status'=>1])}" data-param="" class="am-icon-toggle-off am-text-danger ajax-get" title="设置：显示"></a>
							{/eq}
						</td>
						<td><input type="number" class="am-form-field ipt-sort" data-id="{$vo['id']}" value="{$vo.sort}"></td>
						<td>
							<div class="am-btn-toolbar">
								<div class="am-btn-group am-btn-group-xs">
									<a href="{:url('admin/auth/add',['id'=>$vo['id']])}" class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-plus"></span> 添加</a>
									<a href="{:url('admin/auth/edit',['id'=>$vo['id']])}" class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span> 编辑</a>
									<a href="{:url('admin/auth/delete',['id'=>$vo['id']])}" class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only ajax-delete"><span class="am-icon-trash-o"></span> 删除</a>
								</div>
							</div>
						</td>
					</tr>
					{/foreach}
					

				</tbody>
			</table>
		</div>
	</div>
</div>


{/block}
{block name="js"}
{/block}
{block name="script"}
<script>
$(".ipt-sort").blur(function(){

	$(this).css("background-color","#eee");

	var loading = layer.load(0, {
		shade: false
	});

	var _href = "{:url('admin/auth/setStatus')}";
	
	var id = $(this).data('id');
	var sort = $(this).val();

	
	$.ajax({
		url: _href,
		type: "get",
		data: {'id':id, 'sort':sort},
		success: function(info) {
			layer.close(loading);
		
			if (info.code === 1) {
				layer.msg(info.msg);
			} else {
				layer.msg(info.msg);
			}
		
		}
	});
	return false;

});
</script>
{/block}